diff options
| author | Dawid Rycerz <dawid@rycerz.xyz> | 2025-07-21 21:56:55 +0300 |
|---|---|---|
| committer | Dawid Rycerz <dawid@rycerz.xyz> | 2025-07-21 21:56:55 +0300 |
| commit | c735556726e75428550a3d28a2cf58e2c8490b7d (patch) | |
| tree | fd0ae29d1636b825abeedff6b99d3376bb383135 /src/pages/[...blog]/[category] | |
Initial template
Diffstat (limited to 'src/pages/[...blog]/[category]')
| -rw-r--r-- | src/pages/[...blog]/[category]/[...page].astro | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/pages/[...blog]/[category]/[...page].astro b/src/pages/[...blog]/[category]/[...page].astro new file mode 100644 index 0000000..e1c4ff6 --- /dev/null +++ b/src/pages/[...blog]/[category]/[...page].astro @@ -0,0 +1,37 @@ +--- +import type { InferGetStaticPropsType, GetStaticPaths } from 'astro'; +import { blogCategoryRobots, getStaticPathsBlogCategory } from '~/utils/blog'; + +import Layout from '~/layouts/PageLayout.astro'; +import BlogList from '~/components/blog/List.astro'; +import Headline from '~/components/blog/Headline.astro'; +import Pagination from '~/components/blog/Pagination.astro'; + +export const prerender = true; + +export const getStaticPaths = (async ({ paginate }) => { + return await getStaticPathsBlogCategory({ paginate }); +}) satisfies GetStaticPaths; + +type Props = InferGetStaticPropsType<typeof getStaticPaths> & { category: Record<string, string> }; + +const { page, category } = Astro.props as Props; + +const currentPage = page.currentPage ?? 1; + +const metadata = { + title: `Category '${category.title}' ${currentPage > 1 ? ` — Page ${currentPage}` : ''}`, + robots: { + index: blogCategoryRobots?.index, + follow: blogCategoryRobots?.follow, + }, +}; +--- + +<Layout metadata={metadata}> + <section class="px-4 md:px-6 py-12 sm:py-16 lg:py-20 mx-auto max-w-4xl"> + <Headline>{category.title}</Headline> + <BlogList posts={page.data} /> + <Pagination prevUrl={page.url.prev} nextUrl={page.url.next} /> + </section> +</Layout> |
